Xpath query to select node when attribute does not exist? [closed]
Posted
by Antoine
on Stack Overflow
See other posts from Stack Overflow
or by Antoine
Published on 2008-12-12T14:45:13Z
Indexed on
2010/05/11
4:04 UTC
Read the original article
Hit count: 158
xpath
|attributes
I want to select nodes for which a specific attribute does not exist. I've tried the Not() function, but it doesn't work. Is there a way for this?
Example: The following Xpath query:
group/msg[not(@owner)]
Should retrieve the first node but not the 2nd one. However, both SketchPath (tool to test Xpath queries) and my C# code consider that the 2 nodes are ok.
<group>
<msg id="EVENTDATA_CCFLOADED_XMLCONTEXT" numericId="14026" translate="False" topicId="302" status="translated" >
<text>Context</text>
<comment></comment>
</msg>
<msg id="EVENTDATA_CCFLOADED_XMLCONTEXT_HELP" numericId="14027" translate="False" topicId="302" status="translated" owner="EVENTDATA_CCFLOADED_XMLCONTEXT" >
<text>Provides the new data displayed in the Object.</text>
<comment></comment>
</msg>
</group>
In fact the Not() function works correctly, it's just that I had other conditions and parentheses weren't set correctly. errare humanum est.
© Stack Overflow or respective owner